<template name="home">
	<view>
		<scroll-view>
			<!-- 轮播 -->
			<!--
			<swiper class="screen-swiper square-dot" :indicator-dots="true" :circular="true"
			 :autoplay="true" interval="5000" duration="500" :style="[{animation: 'show 0.2s 1'}]">
				<swiper-item v-for="(item,index) in swiperList" :key="index">
					<image :src="item.url" mode="aspectFill" v-if="item.type=='image'"></image>
					<video :src="item.url" autoplay loop muted :show-play-btn="false" :controls="false" objectFit="cover" v-if="item.type=='video'"></video>
				</swiper-item>
			</swiper>
			-->
			<swiper class="screen-swiper square-dot" :indicator-dots="true" :circular="true"
			 :autoplay="true" interval="5000" duration="500" :style="[{animation: 'show 0.2s 1'}]">
				<swiper-item v-for="(item,index) in swiperList" :key="item.id">
					<image :src="item.imageUrl" mode="aspectFill"></image>
				</swiper-item>
			</swiper>
			
			<!-- 健康服务 -->
			<!-- <view class="cu-bar bg-white solid-bottom" :style="[{animation: 'show 0.5s 1'}]">
				<view class="action">
					< ! -- <image src="/static/icon/icon-64-1.png" style="width: 16px; height: 16px; margin-right:5px;"></image> - - >
					<span class="iconfont text-orange">&#xeb36;</span>
					<text class="text-orange">健康服务</text>
				</view>
			</view> -->
			
			<!-- 服务菜单 -->
			<view class="cu-list grid col-4 text-sm">
				<view class="cu-item animation-slide-bottom" 
					:style="[{animationDelay: (index + 1)*0.05 + 's'}]" 
					v-for="(item,index) in menus" :key="index" >
					<view class="padding text-center" @tap="toMenu(item.code)">
						<image :src="item.icon" style="width:48px;height:48px;"></image>
						<view class="margin-top-xs text-lg">{{item.title}}</view>
					</view>
				</view>
			</view>
			
			<!-- 静态图位 -->
			<view class="static-cons bg-white">
				<view class="item2" @tap="callPlatform()">
					<text class='icon cuIcon-vip'></text>
					<text class="title">医疗呼叫</text>
				</view>
			</view>
			
			<!-- 健康资讯 -->
			<view class="news-con bg-white"
				v-if="cmsNewsList && cmsNewsList.length>0">
				<view class="cu-bar bg-white" :style="[{animation: 'show 0.5s 1'}]">
					<view class="action">
						<text class='cuIcon-news text-orange'></text>
						<text class="text-orange">健康资讯</text>
						<text class="more" @tap="toNewsList">更多+</text>
					</view>
				</view>
				<view class="item" v-for="(item,index) in cmsNewsList" :key="item.id"
					@tap="toNewsDetail(item)">
					<view class="cover-img-con">
						<image class="cover-img" :src="item.coverImg" mode="widthFix"></image>
					</view>
					<view class="text-con">
						<view class="title">{{item.title}}</view>
						<view>
							<text class="author">{{item.author}}</text>
							<text class="issue-time">{{item.createTimeShort}}</text>
							<text class="click-count">{{item.clickCount>0?item.clickCount:0}}人阅读</text>
						</view>
					</view>
				</view>
			</view>
			
			<!-- 服务项目 -->
			<view class="service-item-con bg-white" 
				v-if="serviceItems && serviceItems.length>0">
				<view class="cu-bar" :style="[{animation: 'show 0.5s 1'}]">
					<view class="action">
						<text class='cuIcon-goodsnewfill text-cyan'></text>
						<text class='text-cyan'>服务项目</text>
						<text class="more" @tap="toServiceItem()">更多+</text>
					</view>
				</view>
				<!-- v1 start -->
				<!-- 
				<view class="pages-con" v-if="serviceItems && serviceItems.length>0">
					<view 
						v-for="(item, index) in serviceItems" :key="item.id"
						class="item">
						<view class="image-wrapper">
							<image :src="item.coverimg1" mode="aspectFill"></image>
						</view>
						<view class="text-con">
							<text class="title clamp">{{item.title}}</text>
							<view class="price-box">
								<text class="price">{{item.ylbprice}}</text>
								<text class="sale-count">累计服务{{item.totalsalecount<=0?1:item.totalsalecount}}</text>
							</view>
							<view class="oper">
								<button class="cu-btn bg-cyan round yu-yue"
									@tap="orderServiceItem(item)"><text space="emsp">现在预约</text>
								</button>
							</view>
						</view>
						
					</view>
				</view> 
				-->
				<!-- v1 end -->
				
				<!-- v2 start -->
				<view class="pages-con" v-if="serviceItems && serviceItems.length>0">
					<view 
						v-for="(item, index) in serviceItems" :key="item.id"
						class="item">
						<view class="image-wrapper">
							<image :src="item.coverImage" mode="aspectFill"></image>
						</view>
						<view class="text-con">
							<text class="title clamp">{{item.title}}</text>
							<view class="price-box">
								<text class="price">{{item.ylbprice}}</text>
								<!-- <text class="sale-count">累计服务{{item.totalsalecount<=0?1:item.totalsalecount}}</text> -->
							</view>
							<view class="oper-con">
								<button class="cu-btn bg-cyan round yu-yue-btn"
									@tap="orderServiceItem(item)"><text space="emsp">现在支付</text>
								</button>
								<button class="cu-btn bg-orange round kefu-btn"
									@tap="onlineKefu()"><text space="emsp">客服</text>
								</button>
							</view>
						</view>
						
					</view>
				</view> 
				<!-- v2 end -->
				
			</view>
		</scroll-view>
		<view class="cu-tabbar-height margin-top"></view>
	</view>
</template>

<script>
	import {
		APP_MUST_PERMISSION_STATUS,
		APP_VERSION,
		USER_IDENTITY,
		COMMON_HTTP_ERROR_TIP,
		COMPANY_KEFU_PHONE1,
		DOCTOR_CLIENTID,
			
	} from "@/common/util/constants"
	import { us,os } from '@/common/util/work.js'
	import socket from '@/common/js-sdk/socket/socket.js'
	import moment from 'moment'
	import configService from '@/common/service/config.service.js'
	import mobilePermission from '@/common/util/wa-permission/permission.js'
	import RTM from '../../until/rtm.js'
	//App检测自动更新，任务是否在进行, 避免重复调用(true-进行中, false-执行结束)
	var validAppAutoUpdateRunning = false		
	
	export default {
		name: 'home',
		props:{
			pageCur: String,
		},
		watch: {
			pageCur: {
				immediate: true,
				handler:function(val,oldVal){
				    this.initMenu()
				},
			},
		},
		data() {
			return {
				price:'0.01',
				title:'视频问诊',
				ylbPrice:'0.01',
				urls:'',
				userIdentity: '',
				swiperList: [],			//轮播图
				cmsNewsList: [],		//健康资讯
				serviceItems: [],		//服务项目
				isvip: '',
				flag:'',
				//服务菜单 
				menus: [
					{
					  title:"检测项目",
					  code:'1001',
					  icon:"https://ylb123.oss-cn-hangzhou.aliyuncs.com/app/menu-jian-ce-xiang-mu.png",
					  description:"检测项目",
					  useCount:1000,
					  page:'home'
					},
					{
					  title:"药品配送",
					  code:'1002',
					  icon:"https://ylb123.oss-cn-hangzhou.aliyuncs.com/app/menu-zai-xian-pei-song.png",
					  description:"药品配送",
					  useCount:1000,
					  page:'home'
					},
					/* 
					{
					  title:"体检报告",
					  code:'1004',
					  icon:"/static/home/128/hetong.png",
					  description:"体检报告",
					  useCount:1000,
					  page:'home'
					},
					{
					  title:"诊疗记录",
					  code:'1005',
					  icon:"/static/home/128/toupiao.png",
					  description:"诊疗记录",
					  useCount:1000,
					  page:'home'
					}, */
					{
					  title:"医疗服务",
					  code:'1006',
					  icon:"https://ylb123.oss-cn-hangzhou.aliyuncs.com/app/gongwen.png",
					  description:"医疗服务",
					  useCount:1000,
					  page:'home'
					},
					/* {
					  title:"健康资讯",
					  code:'1007',
					  icon:"/static/home/128/xinwen.png",
					  description:"健康资讯",
					  useCount:1000,
					  page:'home'
					}, */
					{
					  title:"会员充值",
					  code:'1008',
					  icon:"https://ylb123.oss-cn-hangzhou.aliyuncs.com/app/menu-recharge.png",
					  description:"会员充值",
					  useCount:1000,
					  page:'recharge'
					},
					{
					  title:"视频问诊",
					  code:'1009',
					  icon:"https://ylb123.oss-cn-hangzhou.aliyuncs.com/app/menu-jian-kang-dang-an.png",
					  description:"视频问诊",
					  useCount:1000,
					  page:'home'
					},
					{
					  title:"疫苗预约",
					  code:'1010',
					  icon:"https://ylb123.oss-cn-hangzhou.aliyuncs.com/app/menu-hu-li-dao-jia.png",
					  description:"疫苗预约",
					  useCount:1000,
					  page:'home'
					},
					{
					  title:"一键陪诊",
					  code:'1011',
					  icon:"https://ylb123.oss-cn-hangzhou.aliyuncs.com/app/menu-yi-jian-pei-zhen.png",
					  description:"一键陪诊",
					  useCount:1000,
					  page:'home'
					},
					{
					  title:"在线客服",
					  code:'1012',
					  icon:"https://ylb123.oss-cn-hangzhou.aliyuncs.com/app/menu-zai-xian-ke-fu.png",
					  description:"在线客服",
					  useCount:1000,
					  page:'home'
					},
				],
				msgCount:0,
				dot:{
				  mailHome:false
				},
			}
		},
		onLoad(){
			
		},
		created() {
			// #ifdef APP-PLUS
			this.validAutoUpdateApp()	
			// #endif
			this.getUserInfo()
			this.loadWwiperList()
			this.loadServiceItem()
			this.loadCmsNews()
			console.log(8888)
			// this.getdoctorId()
			this.isvip = uni.getStorageSync("CUS_IS_VIP") 
			console.log(this.isvip)
		},
		methods: {
			//获取医生ID
			// getdoctorId(){
			// 	let userIdentity = uni.getStorageSync(USER_IDENTITY)
			// 	console.log('仅对医护人员开放'+ userIdentity);
			// 	if(userIdentity=='1' || userIdentity=='2'){
			// 		let cliendId=uni.getStorageSync(DOCTOR_CLIENTID)
			// 		this.$store.state.uid=cliendId
					
			// 		console.log('仅对医护人员开放'+ this.$store.state.uid);
				
			// 	}
			// },
			//[医护]未读的呼叫记录总数量
			loadNoReadCallCount(){
				let that = this
				that.$http.get("/hujiao/yjhj/queryMsgById", {}).then(res=>{
					if(res.data.success){
						let _count = res.data.result.unreadCount
						if(_count && _count!='0'){
							let _modalContent = '您有 ['+_count+'] 条新的呼叫记录'
							uni.showModal({
								title: '呼叫处理提醒',
								content: _modalContent,
								confirmText: '立即处理',
								showCancel: false,
								success: (showResult) => {
									if (showResult.confirm) {
										//点击-确定
										uni.navigateTo({
											url: '/pages/doctor-nurse/oper-call-list'
										})
									}else{
										//点击-取消
									}
								}
							})
						}
					}else{
						
					}
				}).catch(err => {
				});
			},
			// #ifdef APP-PLUS
			//手机权限验证(必要的项需要开启)
			async validMobileOpenPermisson(){
				//位置权限
				//let _ACCESS_FINE_LOCATION = await mobilePermission.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
				//consooe.log('_ACCESS_FINE_LOCATION = ' + _ACCESS_FINE_LOCATION)
			},
			// #endif
			// #ifdef APP-PLUS
			//检测App是否需要自动更新
			validAutoUpdateApp(){
				if(validAppAutoUpdateRunning){
					return false
				}
				validAppAutoUpdateRunning = true
				
				let that = this
				let _osName = plus.os.name		//Android,
				let _appId = '__UNI__9EC3BDA'	//代码获取appId时得到的是固定字符串'HBuilder', 此处为了分区别同一公司可能拥有多款APP, 采用一款APP对应唯一值(即:和uniapp项目manifest中appid手工保持一致)
				let _version = ''
				
				//获取manifest.json配置文件
				plus.runtime.getProperty(plus.runtime.appid, (wgtInfo) => {})
			},
			// #endif
			// 用户信息
			getUserInfo(){
				this.userIdentity = uni.getStorageSync(USER_IDENTITY)
				if(this.userIdentity!='0'){
					//[医护]呼叫未读数量
					this.loadNoReadCallCount()
				}
			},
			//轮播图-加载
			loadWwiperList(){
				let that = this
				let _params = {
					pageNo: 1,
					pageSize: 5
				}
				that.$http.get("/banner/swiperBanner/list", {params:_params}).then(res=>{
					if(res.data.success){
						that.swiperList = res.data.result.records
					}else{
						that.swiperList = []
						that.$tip.toast(res.data.message);
					}
				}).catch(err => {
					that.swiperList = []
				});
			},
			//健康资讯-加载  
			loadCmsNews(){
				let that = this
				let _params = {
					pageNo: 1,
					pageSize: 5
				}
				
				that.$http.get("/healthcms/cmsNews/list", {params:_params}).then(res=>{
					if(res.data.success){
						that.cmsNewsList = res.data.result.records
						if(that.cmsNewsList && that.cmsNewsList.length>0){
							let _item = {}
							for(let i=0;i<that.cmsNewsList.length;i++){
								_item = that.cmsNewsList[i]
								_item.createTimeShort = moment(_item.createTime).format('YYYY/M/D HH:mm')
							}
						}
					}else{
						that.cmsNewsList = []
						that.$tip.toast(res.data.message);
					}
				}).catch(err => {
					that.cmsNewsList = []
				});
			},
			//服务项目-加载
			loadServiceItem(){
				let that = this
				let _params = {
					pageNo: 1,
					pageSize: 4
				}
				// v1 start
				/* 
				that.$http.get("/prodservice/serviceitems/list", {params:_params}).then(res=>{
					if(res.data.success){
						this.serviceItems = res.data.result.records
					}else{
						this.serviceItems = []
						this.$tip.toast(res.data.message);
					}
				}).catch(err => {
					this.serviceItems = []
				}); 
				*/
				// v1 end
				
				//v2 start
				that.$http.get("/prodservicev2/prodservicev2/list", {params:_params}).then(res=>{
					if(res.data.success){
						this.serviceItems = res.data.result.records
					}else{
						this.serviceItems = []
						this.$tip.toast(res.data.message);
					}
				}).catch(err => {
					this.serviceItems = []
				}); 
				//v2 end
				
			},
			//去健康资讯列表
			toNewsList(){
				uni.navigateTo({
					url: '/pages/news/list'
				})
			},
			//去健康资讯详情
			toNewsDetail(item){
				uni.navigateTo({
					url: '/pages/news/detail?id=' + item.id
				})
			},
			//转向服务项目
			toServiceItem(){
				if(this.userIdentity!='0'){
					this.$tip.toast('仅对会员开放');
					return false;
				}
				this.$emit('changeTabPage', 'serviceItem')
			},
			//服务项目-预约
			orderServiceItem(item){
				if(this.userIdentity!='0'){
					this.$tip.toast('仅对会员开放');
					return false;
				}
				if(!item){
					this.$tip.cyToast('参数错误')
					return false
				}
				/*单条服务项目, 后台返回数据
					{
						coverImage: "https://ylb123.oss-cn-hangzhou.aliyuncs.com/app/service-item-v2-wkcx.jpg"
						description: "专业护士提供上门拆线服务，包括检查伤口，清洁，消毒，拆线服务；80元/次"
						id: "1485141764056096769"
						price: "80"
						title: "外科拆线"
						ylbprice: "80"
					}
				*/
				let modalTitle = item.title
				let modalContent = '建议先在线客服沟通再行预约！\n'
				//orderType: 订单类型(0-会员充值场景, 1-会员按次消费服务项目)
				let nextPageParams = '?nouse=0' + 
					'&orderType=1' + 
					'&serviceItemId=' + item.id
				if(item.description){
				   //服务项目有详情, 则先给会员展示
				   modalContent += item.description
				   uni.showModal({
						title: modalTitle,
						content: modalContent,
						confirmText: '立即下单',
						confirmColor: '#E96141',
						cancelColor: '#999999',
						success: (res) => {
							if (res.confirm) {
								//点击-确定
								uni.navigateTo({
									url: '/pages/order/submit-order' + nextPageParams
								})
							}else{
								//点击-取消
							}
						}
				   })
				}else{
				   //项目没有详情说明
				   uni.showModal({
						title: modalTitle,
						content: modalContent,
						confirmText: '立即下单',
						success: (res) => {
							if (res.confirm) {
								//点击-确定
								uni.navigateTo({
									url: '/pages/order/submit-order' + nextPageParams
								})
							}else{
								//点击-取消
							}
						}
				   })
				}
			},
			initMenu(){
			    this.onSocketOpen()
			    this.onSocketReceive()
			    this.loadCount(0);
			},
			//菜单转向
			toMenu: function(code){
				if(!code){
					return false;
				}
				if(code=='1001'){//检测项目
					uni.navigateTo({
						url: '/pages/check-item/list'
					})
					return false
				}
				console.log(code);
				if(code=='1002'){//在线药品
					uni.navigateTo({
						// url: '/pages/zxyp/list'
						url: '/pages/zxyp/yaodian'
					})
					return false
				}
				
				//20223.1注释
				// if(code=='1002'){//在线配送
				// 	// if(this.userIdentity!='0'){
				// 	// 	this.$tip.toast('仅对会员开放');
				// 	// 	return false;
				// 	// }
				// 	uni.showLoading({
				// 		title: '预约中..',
				// 		mask: true,
				// 	})
				// 	let _params = {
				// 		type:1,		//1-在线配送, 2-护理到家, 3-一键陪诊
				// 	}
				// 	let that = this
				// 	that.$http.post("/yaopin/yjps/add",_params).then(res=>{
				// 		if(res.data.success){
				// 			/*
				// 				{
				// 					address: "陕西省宝鸡市渭滨区清姜街道办事处烽火社区清姜东三路29号"
				// 					description: "一键配送服务，主要对接的是第三方药企，由药企直接配送↵↵↵"
				// 					phone: "0917-3650120"
				// 					title: "宝鸡柏年康成药店 "
				// 				}
				// 			*/
				// 			uni.hideLoading()
				// 			let jsonData = res.data.result
				// 			let _showModalContent = '' +
				// 				'在线配送预约成功!\n' + 
				// 				'['+jsonData.title+']\n' + 
				// 				'电话：' + jsonData.phone
				// 			uni.showModal({
				// 				title: '温馨提示',
				// 				content: _showModalContent,
				// 				confirmText: '确定',
				// 				showCancel: false,
				// 				success: (res) => {
				// 					if (res.confirm) {
										
				// 					}
				// 				}
				// 			})
				// 		}else{
				// 			uni.hideLoading()
				// 			that.$tip.cyToast('预约失败');	
				// 		}
				// 	}).catch(err => {
				// 		uni.hideLoading()
				// 	});
				// 	return false
				// }
				
				
				
				if(code=='1006'){//服务项目
					// if(this.userIdentity!='0'){
					// 	this.$tip.toast('仅对会员开放');
					// 	return false;
					// }
					// this.$emit('changeTabPage', 'serviceItem')
					uni.navigateTo({
						url: '/pages/service-item/service-item'
					})
					return false
				}
				if(code=='1008'){//会员充值
					// if(this.userIdentity!='0'){
					// 	this.$tip.toast('仅对会员开放');
					// 	return false;
					// }
					uni.navigateTo({
						url: '/pages/recharge/recharge'
					})
					return false
				}
				if(code=='1009'){//健康档案
					 
					// if(this.userIdentity!='0'){
					// 	this.$tip.toast('仅对会员开放');
					// 	return false;
					// }
					
					// uni.showLoading({
					// 	title: '连线中..',
					// 	mask: true,
					// })
				    
					uni.navigateTo({						
						url: '/pages/sphj/zhifu?price=' + this.price +  "&ylbprice="+ this.ylbPrice
					})
					
					//判断用户是否在10分钟内支付	
					// this.$http.get('/orderinfo/callOrders/betwenOrder').then(res=>{
					// 	if(res.data.success){
							
					// 		if(res.data.result){
					// 			uni.hideLoading()
					// 			uni.navigateTo({									
					// 				url: '/pages/sphj/index?price=' + this.price +  "&ylbprice="+ this.ylbPrice
					// 			})
					// 		}
					// 	}
					// })
					
					
					
				
					return false
				}
				if(code=='1010'){//护理到家
					// if(this.userIdentity!='0'){
					// 	this.$tip.toast('仅对会员开放');
					// 	return false;
					// }
					//跳转到疫苗预约
					uni.navigateTo({
						// url: '/pages/member-health-record/list?code=' + code
						url: '/pages/ymyy/ymyy'
					})
					uni.showLoading({
						title: '预约中..',
						mask: true,
					})
					let _params = {
						type:2,		//1-在线配送, 2-护理到家, 3-一键陪诊
					}
					let that = this
					that.$http.post("/track/userTrack/add",_params).then(res=>{
						if(res.data.success){
							/*
								{
									phone: "0917-3650120"
								}
							*/
							uni.hideLoading()
							let jsonData = res.data.result
							let _showModalContent = '' +
								'护理到家预约成功!\n' + 
								'了解进度或其它护理问题欢迎致电\n' + 
								'' + jsonData.phone
							// uni.showModal({
							// 	title: '温馨提示',
							// 	content: _showModalContent,
							// 	confirmText: '确定',
							// 	showCancel: false,
							// 	success: (res) => {
							// 		if (res.confirm) {
										
							// 		}
							// 	}
							// })
						}else{
							uni.hideLoading()
							that.$tip.cyToast('预约失败');	
						}
					}).catch(err => {
						uni.hideLoading()
					});
					return false
				}
				if(code=='1011'){//一键陪诊
					if(this.userIdentity!='0'){
						this.$tip.toast('仅对会员开放');
						return false;
					}
					
					uni.showLoading({
						title: '预约中..',
						mask: true,
					})
					let _params = {
						type:3,		//1-在线配送, 2-护理到家, 3-一键陪诊
					}
					let that = this
					that.$http.post("/track/userTrack/add",_params).then(res=>{
						if(res.data.success){
							/*
								{
									phone: "0917-3650120"
								}
							*/
							uni.hideLoading()
							let jsonData = res.data.result
							let _showModalContent = '' +
								'一键陪诊预约成功!\n' + 
								'了解进度或其它护理问题欢迎致电\n' + 
								'' + jsonData.phone
							uni.showModal({
								title: '温馨提示',
								content: _showModalContent,
								confirmText: '确定',
								showCancel: false,
								success: (res) => {
									if (res.confirm) {
										
									}
								}
							})
						}else{
							uni.hideLoading()
							that.$tip.cyToast('预约失败');	
						}
					}).catch(err => {
						uni.hideLoading()
					});
					return false
				}
				if(code=='1012'){//在线客服
					//this.$tip.toast('在线客服业务接入中...');
					/* uni.navigateTo({
						url: '/pages/kefu/kefu'
					}) */
					this.onlineKefu()
					/* uni.showModal({
						title: '在线服务',
						content: '欢迎您致电：' + COMPANY_KEFU_PHONE1 + '\n后续我司将开通更多客服沟通方式\n感谢您的支持！',
						confirmText: '确定',
						showCancel: false,
						success: (showResult) => {
							if (showResult.confirm) {
								
							}
						}
					}) */
					return false
				}
			},
			//在线客服
			onlineKefu(){
				uni.showLoading({
					title: '调度中..',
					mask: true,
				})
				let that = this
				that.$http.get("/onlineservice/wxkf/list", {}).then(res=>{
					if(res.data.success){
						uni.hideLoading()
						/*返回数据结构, 是个数组, 取第一个即可
							[
								{
									groupId: "ww5f63ceded24818ab"
									url: "https://work.weixin.qq.com/kfid/kfcc5d6030bea412d37"
								}
							]
						*/
						let jsonData = res.data.result.records
						if(!jsonData || jsonData.length<1){
							that.$tip.cyToast('微信客服参数错误')
							return false
						}
						if(!jsonData[0].groupId || !jsonData[0].url){
							that.$tip.cyToast('微信客服参数错误')
							return false
						}
						
						// #ifdef APP-PLUS
						let weiXinKefuInfo = {
							corpid: jsonData[0].groupId,
							kefuUrl: jsonData[0].url,
						}
						that.openWeiXinKefu(weiXinKefuInfo)
						// #endif
					}else{
						uni.hideLoading()
						that.$tip.cyToast('坐席繁忙，请稍后再试');
					}
				}).catch(err => {
					uni.hideLoading()
				});
			},
			//接入微信客服
			openWeiXinKefu(weiXinKefuInfo){
				// #ifdef APP-PLUS
				if(!weiXinKefuInfo || !weiXinKefuInfo.corpid || !weiXinKefuInfo.kefuUrl){
					this.$tip.cyToast('微信客服参数错误')
					return false
				}
				
				let sweixin = null
				plus.share.getServices(res=>{
					sweixin = res.find(i => i.id === 'weixin')
					if(sweixin){
						sweixin.openCustomerServiceChat({
							//微信客服-企业ID
							corpid: weiXinKefuInfo.corpid,    	
							//微信客服-某个客服的URL
							url: weiXinKefuInfo.kefuUrl,
						},suc=>{
							//console.log("success",JSON.stringify(res))
						},err=>{
							//console.log("error",JSON.stringify(err))
						})
					}else{
						plus.nativeUI.alert('当前环境不支持微信操作!')
					}
				},function(){
					uni.showToast({title: "获取服务失败，不支持该操作。"+JSON.stringify(e), icon: 'error'})
				})
				// #endif
				// #ifndef APP-PLUS
				window.location.href = "https://work.weixin.qq.com/kfid/kfcc5d6030bea412d37"
				// #endif
			},
			goPage(page){
				if(!page){
					return false;
				}
				if(page==='annotationList'){
				  this.msgCount = 0
				}
				this.dot[page]=false
				this.$Router.push({name: page})
			},
			//呼叫医疗帮
			callPlatform(){
				// if(this.userIdentity!='0'){
				// if(this.isvip!='Y' ){
				// 	this.$tip.toast('仅对付费会员开放');
				// 	return false;
				// }
				uni.showModal({
					title: '提示',
					content: '请再次确认呼叫，谢谢！',
					cancelText: '取消',
					confirmText: '确认',
					success: res => {
						if (res.confirm) {
							uni.showLoading({
								title: '呼叫中请稍后...'
							});
							let that = this
							that.$http.post("/hujiao/yjhj/add",{}).then(res=>{
								uni.hideLoading();
								/* if(res.data.success){
									that.$tip.toast(res.data.result);
								}else{
									that.$tip.toast(res.data.result);
								} */
								uni.showModal({
									title: '',
									content: res.data.result,
									confirmText: '我知道了',
									showCancel: false,
									success: (showResult) => {
										if (showResult.confirm) {
										}
									},
								})
							}).catch(e => {
								uni.hideLoading();
							});
						
						}
					}
				})
				
			},
			// 启动webSocket
			onSocketOpen() {
				socket.init('websocket');
			},
			onSocketReceive() {
				var _this=this
				socket.acceptMessage = function(res){
					if(res.cmd == "topic"){
					  //系统通知
					  _this.loadCount('1')
					}else if(res.cmd == "user"){
					  //用户消息
					  _this.loadCount('2')
					} else if(res.cmd == 'email'){
					 //邮件消息
					  _this.loadEmailCount()
					}
				}
			},
			//此接口暂废弃 2022-01-16 12:56
			loadCount(flag){
				/* let url = '/sys/annountCement/listByUser';
				this.$http.get(url).then(res=>{
				  if(res.data.success){
					let msg1Count = res.data.result.anntMsgTotal;
					let msg2Count = res.data.result.sysMsgTotal;
					this.msgCount = msg1Count + msg2Count
				  }
				}) */
			},
			loadEmailCount(){
				this.dot.mailHome = true
			},
			getTtemDotInfo(item){
				if(item.page==='annotationList' && this.msgCount>0){
				  return this.msgCount
				}
				return '';
			},
			//点击菜单-跳转到具体页面
			/* toMenuPage(code){
				if(!code){
					return false;
				}
				if(code=='menu008'){
					this.toRecharge()
					return false;
				}
			}, */
			//会员充值 
			toRecharge(){
				uni.navigateTo({
					url: '/pages/recharge/recharge'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.cu-list.grid>.cu-item {
	  padding: 0px 0px; 
	}
    .line2-icon {
	  width: 60px;
	  height: 60px;
    }
	/* 静态图块 */
	.static-cons{
		width: 100%;
		clear: both;
		display: block;
		height: auto;
		overflow: hidden;
		padding: 20upx;
		.icon{
			font-size: 70upx;
			color: #ffffff;
			margin-right: 20upx;
		}
		.title{
			color: #ffffff;
			font-size: 56upx;
			text-shadow: 2px 2px 2px #f87a48;
			position: relative;
			top: -5upx;
		}
		.item1{
			float: left;
			width: 100%;
			height: 150upx;
			line-height: 150upx;
			text-align: center;
			border-radius: 16upx;
			overflow: hidden;
			background: url(https://ylb123.oss-cn-hangzhou.aliyuncs.com/app/call-bg-1.jpg) 100% no-repeat;
			background-size: 100%;
		}
		.item2{
			float: right;
			width: 100%;
			height: 150upx;
			line-height: 150upx;
			text-align: center;
			border-radius: 16upx;
			overflow: hidden;
			background: url(https://ylb123.oss-cn-hangzhou.aliyuncs.com/app/call-bg-2.jpg) 100% no-repeat;
			background-size: 100%;
		}
	}
	
	
	/* 健康资讯 */
	.news-con{
		margin-top: 20upx;
		padding-bottom: 16upx;
		.action{
			.more{
				font-size: 24upx;
				position: absolute;
				right: 20upx;
				color: #aaaaaa;
			}
		}
		.item{
			display:flex;
			with: 100%;
			border-bottom: 1px dashed #ececec;
			padding: 20upx;
			overflow: hidden;
			.cover-img-con{
				flex:1;
				image{
					width: 140upx;
					height: 70upx;
					border-radius: 10upx;
				}
			}
			&:last-child{
				border-bottom: 0;
				margin-bottom: 0;
				padding-bottom: 0;
			}
			.text-con{
				flex:4;
				margin-left: 16upx;
				font-size: 26upx;
				color: #999999;
				overflow: hidden;
				.title{
					text-overflow: ellipsis;
					white-space: nowrap;
					overflow: hidden;
					font-size: 36upx;
					color: #666666;
					margin-bottom: 20upx;
				}
				.author{
					margin-right: 24upx;
				}
				.issue-time{
					margin-right: 24upx;
				}
				.click-count{
					float: right;
				}
			}
		}
	}
	
	/* 服务项目 */
	.service-item-con{
		margin-top: 20upx;
		.action{
			.more{
				font-size: 24upx;
				position: absolute;
				right: 20upx;
				color: #aaaaaa;
			}
		}
		.pages-con{
			display:flex;
			flex-wrap:wrap;
			padding: 20upx 20upx 0 20upx;
			.item{
				display:flex;
				flex-direction: column;
				width: 48%;
				overflow: hidden;
				background-color: #fff;
				margin-bottom: 25upx;
				border-radius: 15upx;
				border: 1px solid #ececec;
				&:nth-child(2n+1){
					margin-right: 4%;
				}
			}
			.image-wrapper{
				width: 100%;
				height: 330upx;
				/* border-radius: 10upx; */
				overflow: hidden;
				image{
					width: 100%;
					height: 100%;
				}
			}
			.text-con{
				padding: 15upx;
				.title{
					/* text-overflow: ellipsis;
					white-space: nowrap;
					overflow: hidden; */
					font-size: $uni-font-size-lg;
					color: $uni-text-color;
					height: 50upx;
					line-height: 50upx;
					overflow: hidden;
					border: 0px solid #f00;
					margin: 10upx 0;
				}
				.price-box{
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding-right: 10upx;
					margin-top: 10upx;
					font-size: 24upx;
					color: $uni-text-color-grey;
					.price{
						color: $uni-color-dc4c47;
						line-height: 36upx;
						font-size: 36upx;
						font-weight: bold;
						&:before{
							content: '￥';
							font-size: 20upx;
						}
						&:after{
							content: ' / 次';
							font-size: 20upx;
						}
					}
					.sale-count{
						font-size:$uni-font-size-sm;
						color: #999999;
						line-height: 1;
						&:after{
							content: '次';
						}
					}
				}
				.oper-con{
					font-size: 26upx;
					margin: 15upx 0 0 0;
					.yu-yue-btn{
						float: right;
					}
					.kefu-btn{
					}
				}
			}			
		}
	}
	
	/* 推荐商品 */
	.goods-con{
		display:flex;
		flex-wrap:wrap;
		padding: 0 30upx;
		background: #fff;
		.guess-item{
			display:flex;
			flex-direction: column;
			width: 48%;
			padding-bottom: 40upx;
			&:nth-child(2n+1){
				margin-right: 4%;
			}
		}
		.image-wrapper{
			width: 100%;
			height: 330upx;
			border-radius: 3px;
			overflow: hidden;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.title{
			/* text-overflow: ellipsis;
			white-space: nowrap;
			overflow: hidden; */
			font-size: $uni-font-size-lg;
			color: $uni-text-color;
			height: 90upx;
			line-height: 45upx;
			overflow: hidden;
		}
		.price-box{
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding-right: 10upx;
			font-size: 24upx;
			color: $uni-text-color-grey;
			.price{
				font-size: $uni-font-size-lg;
				color: $uni-color-error;
				line-height: 1;
				&:before{
					content: '￥';
					font-size: 26upx;
				}
			}
		}
		.sale-count{
			font-size:$uni-font-size-lg;
			color: $uni-text-color;
			line-height: 1;
		}
	}
</style>
